#ifndef REFLOW_PREDICATE_INTRINSICINST_H
#define REFLOW_PREDICATE_INTRINSICINST_H

#include "llvm/ADT/STLExtras.h"
#include "llvm/IR/IntrinsicInst.h"

namespace llvm {
class PredicatedInst : public CallInst {
public:
  static const char *tag() { return "fpga.predicate"; }

  static inline bool classof(const CallInst *I) {
    return I->getOperandBundle(tag()) != None;
  }

  static inline bool classof(const Value *V) {
    return isa<CallInst>(V) && classof(cast<CallInst>(V));
  }

  Value *getPredicate() const;
  bool isTriviallyDead() const;

  uint64_t getOccurence() const;

  void addOccurence(uint64_t Occurence);

  void getOperandBundlesAsDefsWithoutPredicate(
      SmallVectorImpl<OperandBundleDef> &Defs);

  static bool Simplify(PredicatedInst *PI);
};
} // namespace llvm

#endif // REFLOW_PREDICATE_INTRINSICINST_H
